build(ci): add --base/--head changed-files support to validate-frontmatter - #2499
Conversation
The CI workflow calls `npm run validate:frontmatter:changed -- --base $BASE_SHA --head $HEAD_SHA` but the script previously ignored those flags and validated all files. This change: - Adds `FileDiscovery.findChangedFiles(baseSha, headSha, ...)` which uses `git diff --name-only --diff-filter=ACMRT` (via execFileSync, no shell interpolation) to get changed files, then intersects with the set of pattern-matched/non-excluded files; falls back to full scan on any error. - Validates SHA format (4–64 hex chars) before use to prevent shell injection. - Updates `validateFrontmatter(filePaths?)` to accept an optional file list. - Parses `--base`/`--head` in the CLI and passes the changed-file list to the validator when both are present. - Chains `.catch()` on both `validateFrontmatter()` call sites so unhandled rejections cause a non-zero exit (CI correctness fix). - Updates `--help` output to document the new flags. Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
…rontmatter-change
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR fixes the validate:frontmatter:changed CI workflow path by adding --base/--head support so frontmatter validation can scope to only files changed between two git SHAs, while retaining a full-scan fallback.
Changes:
- Added
FileDiscovery.findChangedFiles(baseSha, headSha, ...)to compute changed files viagit diff --name-onlyand filter them to supported patterns/exclusions. - Updated
validateFrontmatter(filePaths?)and CLI arg parsing to validate only changed files when--baseand--headare provided. - Ensured async validation invocations surface failures via
.catch()with non-zero exit codes.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ash Shaw <ashley@lightspeedwp.agency>
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
1 similar comment
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
Head branch was pushed to by a user without write access
…e CI diagnostics Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
1 similar comment
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
The CI workflow calls `npm run validate:frontmatter:changed -- --base $BASE_SHA --head $HEAD_SHA` but the script previously ignored those flags and validated all files. This change: - Adds `FileDiscovery.findChangedFiles(baseSha, headSha, ...)` which uses `git diff --name-only --diff-filter=ACMRT` (via execFileSync, no shell interpolation) to get changed files, then intersects with the set of pattern-matched/non-excluded files; falls back to full scan on any error. - Validates SHA format (4–64 hex chars) before use to prevent shell injection. - Updates `validateFrontmatter(filePaths?)` to accept an optional file list. - Parses `--base`/`--head` in the CLI and passes the changed-file list to the validator when both are present. - Chains `.catch()` on both `validateFrontmatter()` call sites so unhandled rejections cause a non-zero exit (CI correctness fix). - Updates `--help` output to document the new flags. Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ash Shaw <ashley@lightspeedwp.agency>
…e CI diagnostics Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
caeb4cf to
6ed087d
Compare
❌ Branch Name Validation FailedThe branch name Required Format
Allowed Branch Types
Valid Examples
Invalid Examples
SolutionRename your branch to follow the pattern and update the PR. For more information, see docs/BRANCHING_STRATEGY.md. |
…rontmatter-change
Co-authored-by: ashleyshaw <1805352+ashleyshaw@users.noreply.github.com>
Head branch was pushed to by a user without write access
…nge' of https://github.com/lightspeedwp/.github into ci/fix-missing-npm-script-validate-frontmatter-change
- Revert unnecessary libc field removals that were incidental npm regeneration - Keeps only the intentional changes to validate-frontmatter script Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
…ntmatter-change Resolved merge conflicts: - package-lock.json: Used origin/develop version (incidental changes) - validate-frontmatter.js: Kept PR's improved --base/--head parameter approach PR adds proper support for changed-files validation with --base/--head SHA flags. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
🔍 Reviewer Summary for PR #2499CI Status: ❌ Recommendations
|
|
✅ PR checklists finalised after merge. |
Summary
The
front-matter-validateCI check was failing on every PR becausenpm run validate:frontmatter:changedexisted inpackage.jsonbut the underlying script ignored the--base/--headSHA flags passed by the workflow — effectively running a full scan on every invocation and providing no "changed files only" behaviour.Changes Made
FileDiscovery.findChangedFiles(baseSha, headSha, ...)— new static method; runsgit diff --name-only --diff-filter=ACMRTviaexecFileSync(arg array, no shell) and intersects results with the pattern-matched/excluded file set; falls back to full scan gracefully on any git errorvalidateFrontmatter(filePaths?)— accepts an optional file list; CLI wires it up when both--baseand--headare present, full scan otherwisevalidateFrontmatter()call sites now chain.catch()so async rejections produce a non-zero exit rather than a silent passKey Features
BASE_SHAandHEAD_SHAare validatedexecFileSync(argument array) — no shell involved, no injection surface/^[0-9a-f]{4,64}$/i— covers abbreviated and full SHAsTesting
CI invocation now resolves correctly:
Linked Issues
Fixes #1929
Checklist (Global DoD / PR)